import pandas as pd
import numpy as np
from .feature_decorator import support_predict

@support_predict
def prepare_features(df):
    """添加季节性特征"""
    dates = pd.to_datetime(df.iloc[:, 0])
    
    # 基础特征
    year = dates.dt.year
    month = dates.dt.month
    
    # 重要的季节性特征
    month_sin = np.sin(2 * np.pi * month/12)
    month_cos = np.cos(2 * np.pi * month/12)
    quarter = dates.dt.quarter
    
    X = np.column_stack([
        year,
        month,
        month_sin,
        month_cos,
        quarter
    ])
    y = df.iloc[:, 1].values
    return X, y